home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / Expander / Expander Classes / CFamily.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-30  |  2.8 KB  |  102 lines  |  [TEXT/KAHL]

  1. /***********************************************************************************
  2.     CFamily.h
  3.  
  4.     Copyright © 1994 B-Ray Software. All rights reserved.
  5.     Developed using Symantec C++ 7.0.2 and Symantec's TCL library.
  6.     Portions of this code courtesy Symantec, Inc.
  7.  
  8.     This code may be freely distributed as long as this notice remains. This code
  9.     may not be used in any commercial software without the consent of B-Ray Software.
  10.  
  11.     ---
  12.  
  13.     Header file for CFamily class
  14.  
  15. ***********************************************************************************/
  16.  
  17. #pragma once
  18.  
  19. #include <CPtrArray.h>
  20. #include <CPane.h>
  21.  
  22.  
  23. #define CFamilyList        CPtrArray<CFamily>
  24.  
  25.  
  26. class CFamily {
  27.  
  28. TCL_DECLARE_CLASS
  29.  
  30. protected:
  31.     CFamily        *itsParent;            // parent of the family
  32.     CFamilyList    *itsChildren;        // children we have
  33.  
  34. public:
  35.     CFamily();
  36.     virtual ~CFamily();
  37.  
  38.     virtual void    SetParent( CFamily *aParent )
  39.                         { itsParent = aParent; };
  40.     virtual CFamily    *GetParent( void )
  41.                         { return itsParent; };
  42.  
  43.     /*
  44.      * Child add/delete methods
  45.      */
  46.     virtual void    AppendChild( CFamily *aChild )
  47.                         { InsertChildAt( aChild, GetNumberChildren() + 1 ); };
  48.     virtual void    PrependChild( CFamily *aChild )
  49.                         { InsertChildAt( aChild, 1 ); };
  50.     virtual void    InsertChildAt( CFamily *aChild, long index );
  51.     virtual void    InsertChildAfter( CFamily *aChild, CFamily *afterChild )
  52.                         { InsertChildAt( aChild, FindChildIndex( afterChild ) + 1 ); };
  53.     virtual void    RemoveChildAt( long index );
  54.  
  55.     /*
  56.      * Child access methods
  57.      */
  58.     virtual CFamily    *GetChildAtIndex( long index )
  59.                         { return ( itsChildren && index > 0 && index <= GetNumberChildren() ) ? 
  60.                                    itsChildren->NthItem( index ) : NULL; };
  61.     virtual CFamily    *NextChild( long index )
  62.                         { return GetChildAtIndex( index + 1 ); };
  63.     virtual CFamily    *PrevChild( long index )
  64.                         { return GetChildAtIndex( index - 1 ); };
  65.     virtual CFamily    *FirstChild( void )
  66.                         { return GetChildAtIndex( 1 ); };
  67.     virtual CFamily    *LastChild( void )
  68.                         { return GetChildAtIndex( GetNumberChildren() ); };
  69.     virtual CFamily    *ResolveToLeaf( Boolean beginOrEnd );
  70.  
  71.     /*
  72.      * Misc. child methods
  73.      */
  74.     virtual long    FindChildIndex( CFamily *aChild )
  75.                         { return itsChildren ? itsChildren->FindIndex( aChild ) : 0; };
  76.  
  77.     virtual long    GetNumberChildren( void )
  78.                         { return itsChildren ? itsChildren->GetNumItems() : 0; };
  79.  
  80.     /*
  81.      * Pane/Child conversions
  82.      */
  83.     virtual CPane    *ChildToPane() = 0;
  84.     virtual CFamily    *PaneToChild() = 0;
  85.  
  86.     /*
  87.      * Messaging functions
  88.      */
  89.     virtual void    TellChildren( long message, void *param );
  90.     virtual void    TellParent( long message, void *param );
  91.  
  92.     virtual void    ChildMessage( CFamily *aChild, long message, void *param );
  93.     virtual void    ParentMessage( long message, void *param );
  94.  
  95.     /*
  96.      * Stream functions
  97.      */
  98.     virtual void    PutTo( CStream &stream );
  99.     virtual void    GetFrom( CStream &stream );
  100.  
  101. };
  102.